﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using ProjScan.Config;
using ProjScan.Tools;
using UnityEngine;

namespace ProjScan.ScanRule
{
	// Token: 0x020001A2 RID: 418
	internal abstract class BaseRule
	{
		// Token: 0x06000E0F RID: 3599
		public abstract bool CheckSupportability(out string msg);

		// Token: 0x17000347 RID: 839
		// (get) Token: 0x06000E10 RID: 3600 RVA: 0x00040100 File Offset: 0x0003E300
		public virtual string RuleKey
		{
			get
			{
				return base.GetType().FullName.Substring("ProjScan.ScanRule.".Length);
			}
		}

		// Token: 0x17000348 RID: 840
		// (get) Token: 0x06000E11 RID: 3601 RVA: 0x0004012C File Offset: 0x0003E32C
		public virtual string OutputPath
		{
			get
			{
				return Path.Combine(ToolsHelper.GetFailResultPath(), this.RuleKey + ".csv");
			}
		}

		// Token: 0x17000349 RID: 841
		// (get) Token: 0x06000E12 RID: 3602 RVA: 0x00040158 File Offset: 0x0003E358
		public virtual string DetailOutputPath
		{
			get
			{
				return Path.Combine(ToolsHelper.GetFailDetailPath(), this.RuleKey + ".csv");
			}
		}

		// Token: 0x06000E13 RID: 3603 RVA: 0x00040184 File Offset: 0x0003E384
		public virtual float GetThresholds(float defaultValue)
		{
			float thresholds = Singleton<QAOnlineSettings>.Instance.GetThresholds(this.RuleKey);
			return (thresholds >= 0f) ? thresholds : defaultValue;
		}

		// Token: 0x06000E14 RID: 3604 RVA: 0x000401B4 File Offset: 0x0003E3B4
		public virtual void DeleteOutputFile()
		{
			bool flag = File.Exists(this.OutputPath);
			if (flag)
			{
				File.Delete(this.OutputPath);
			}
		}

		// Token: 0x06000E15 RID: 3605 RVA: 0x000401E0 File Offset: 0x0003E3E0
		public virtual void CreateNewOutputFile()
		{
			using (FileStream fileStream = File.Open(this.OutputPath, FileMode.Create))
			{
				using (StreamWriter streamWriter = new StreamWriter(fileStream))
				{
					string value = "\"Location\",\"ShouldBeFixed\",\"ShouldJoinWhiteList\",\"IsFixed\"";
					streamWriter.WriteLine(value);
				}
			}
		}

		// Token: 0x06000E16 RID: 3606 RVA: 0x00002A20 File Offset: 0x00000C20
		public virtual void OutputData(bool append = false)
		{
		}

		// Token: 0x06000E17 RID: 3607 RVA: 0x00002A20 File Offset: 0x00000C20
		public virtual void CreateNewOutputDetailFile()
		{
		}

		// Token: 0x06000E18 RID: 3608 RVA: 0x00002A20 File Offset: 0x00000C20
		public virtual void OutputDetailData()
		{
		}

		// Token: 0x06000E19 RID: 3609
		public abstract void DumpToRuleCSV(ref StreamWriter sw);

		// Token: 0x06000E1A RID: 3610
		public abstract void DumpToThresCSV(ref StreamWriter sw);

		// Token: 0x06000E1B RID: 3611 RVA: 0x00002A20 File Offset: 0x00000C20
		public virtual void FixRule()
		{
		}

		// Token: 0x06000E1C RID: 3612 RVA: 0x00002A20 File Offset: 0x00000C20
		public virtual void Init()
		{
		}

		// Token: 0x06000E1D RID: 3613 RVA: 0x0004024C File Offset: 0x0003E44C
		public virtual bool InvokeFixer(string resourcePath)
		{
			bool flag = this.fixerType == null;
			bool result;
			if (flag)
			{
				Debug.LogWarning("Scan：规则" + base.GetType().Name.ToString() + " 的修复功能未实现");
				result = false;
			}
			else
			{
				try
				{
					object obj = Activator.CreateInstance(this.fixerType);
					MethodInfo method = this.fixerType.GetMethod("Fix");
					object[] parameters = new object[]
					{
						resourcePath
					};
					FixLog.Instance.Log(this.fixerType, resourcePath);
					result = (bool)method.Invoke(obj, parameters);
				}
				catch (Exception ex)
				{
					FixLog.Instance.Log(FixLog.LogLevel.EXCEPTION, FixLog.FixStage.f4, string.Concat(new string[]
					{
						(ex.GetType() == null) ? null : ex.GetType().ToString(),
						"\n",
						ex.Message,
						"\n",
						ex.StackTrace
					}));
					result = false;
				}
			}
			return result;
		}

		// Token: 0x06000E1E RID: 3614 RVA: 0x00007118 File Offset: 0x00005318
		public void SetDataID(int did)
		{
			this.dataID = did;
		}

		// Token: 0x1700034A RID: 842
		// (get) Token: 0x06000E1F RID: 3615 RVA: 0x0004035C File Offset: 0x0003E55C
		// (set) Token: 0x06000E20 RID: 3616 RVA: 0x00007122 File Offset: 0x00005322
		public virtual string TableTag
		{
			get
			{
				return this.m_TableTag;
			}
			set
			{
				this.m_TableTag = value;
			}
		}

		// Token: 0x1700034B RID: 843
		// (get) Token: 0x06000E21 RID: 3617 RVA: 0x00040374 File Offset: 0x0003E574
		// (set) Token: 0x06000E22 RID: 3618 RVA: 0x0000712C File Offset: 0x0000532C
		public virtual int? SceneId
		{
			get
			{
				return this.m_SceneId;
			}
			set
			{
				this.m_SceneId = value;
			}
		}

		// Token: 0x1700034C RID: 844
		// (get) Token: 0x06000E23 RID: 3619 RVA: 0x0004038C File Offset: 0x0003E58C
		// (set) Token: 0x06000E24 RID: 3620 RVA: 0x00007136 File Offset: 0x00005336
		public virtual string SceneName
		{
			get
			{
				return this.m_SceneName;
			}
			set
			{
				this.m_SceneName = value;
			}
		}

		// Token: 0x040008CB RID: 2251
		private string m_TableTag;

		// Token: 0x040008CC RID: 2252
		private int? m_SceneId;

		// Token: 0x040008CD RID: 2253
		private string m_SceneName;

		// Token: 0x040008CE RID: 2254
		protected int dataID;

		// Token: 0x040008CF RID: 2255
		public Type fixerType;

		// Token: 0x040008D0 RID: 2256
		public Dictionary<string, FailedAssetInfo> failAssetInfos;
	}
}
